package com.yxs.yapp.utils;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.Toast;
import android.content.pm.PackageManager;

public class YIntent {
    private YIntent() {}
    
    public static boolean openWebPage(Context context, String url) {
        try {
            Uri webpage = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, webpage);

            // 检查是否有浏览器可以处理此Intent
            if (intent.resolveActivity(context.getPackageManager()) != null) {
                context.startActivity(intent);
                return true;
            } else {
                YView.ShortToast(context, "没有可用的浏览器");
                return false;
            }
        } catch (Exception e) {
            YView.ShortToast(context, "打开链接时发生错误");
            e.printStackTrace();
            return false;
        }
    }
    
    
}
